<?
include('seguridad.php');
include('bd.php');
Conectar();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> BideYoday </TITLE>
  <META NAME="Generator" CONTENT="DILAPER">
  <META NAME="Author" CONTENT="Power by Sebastian Costa - Design: Nadia De Cinti">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
  <link href="../style.css" rel="stylesheet" type="text/css">
  <script src="../js/botonera.js" type="text/javascript"></script>
 </HEAD>

 <BODY topmargin="0">
<center>
<table width="990" height="100%" cellspacing="0" cellpadding="0" class="fondo" border="0">
	<tr>
		<td width="100%" height="100%" align="center" valign="top">
			<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
				<tr>
					<td align="center" valign="top">
<div style="height: 135px"></div>
<!-- contenido -->
<table width="800"  border="0" class="admin_area" cellspacing="0" cellpadding="0">
	<tr bgcolor="#ffffff">
		<td align="right" height="30">
Welcome <?echo $_SESSION['usuario'];?>&nbsp;|&nbsp;<a href="salir.php"><font color="red">Log Out</font></a>&nbsp;&nbsp;
		</td>
	</tr>	
	<tr><td height="3"></td></tr>
	<tr bgcolor="#ffffff">
		<td align="right" height="50">
<?include('menu.php');?>
		</td>
	</tr>	
	<tr><td height="3"></td></tr>
	<tr bgcolor="#ffffff">
		<td align="left" valign="top" height="300"  class="tabla_central">
<div style="margin: 10px">
<b><span class="titulo_admin">Products</span></b><br>
<br>
<a href="products_new.php" class="admin_link">New product</a>&nbsp;|&nbsp;
<a href="products_shape.php" class="admin_link">To define Shape</a>&nbsp;|&nbsp;
<a href="products_color.php" class="admin_link">To define color</a><br>
<br>
<table width="100%" border="0" class="tabla_admin">
	<tr>
		<td align="center" bgcolor="#ffffff">
<b>Image</b>
		</td>
		<td align="center" bgcolor="#ffffff">
<b>Code</b>
		</td>
		<td align="center" bgcolor="#ffffff">
<b>Name</b>
		</td>
		<td align="center" bgcolor="#ffffff">
<b>Preci</b>
		</td>
		<td align="center" bgcolor="#ffffff">
<b>Stock</b>
		</td>
		<td align="center" bgcolor="#ffffff">
<b>On Line</b>
		</td>
		<td align="center" bgcolor="#ffffff">
<b>In Home</b>
		</td>
		<td align="center" bgcolor="#ffffff">
<b>Promotions</b>
		</td>
		<td align="center" bgcolor="#ffffff">
<b>Actions</b>
		</td>
	</tr>
<?
$result=mysql_query("SELECT * FROM products ORDER BY id DESC");
$w=1;
while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
	if($bg_num%2==0){
$bg='bgcolor="#B4B4B4"';
}else{
$bg='bgcolor="#DDDDDD"';
}
?>

	<tr id="d_<?echo$w;?>">
		<td align="left" <?echo$bg;?>>
	<?if(file_exists('../img_products/'.$row[code].'-1_c.jpg')){?>
<img src="../img_products/<?echo $row[code]?>-1_c.jpg">
	<?}else{echo'<font color="red">WITHOUT PHOTO,<br>I DO NOT KNOW IT PUBLISHES</font>';}?>
		</td>
		<td align="left" <?echo$bg;?>>
<div style="margin-left: 5px; margin-right: 5px;"><?echo$row[code];?></div>
		</td>
		<td align="left" <?echo$bg;?>>
<div style="margin-left: 5px; margin-right: 5px;"><?echo$row[name];?><br><?echo$row[modle];?></div>
		</td>
		<td align="left" <?echo$bg;?>>
<?
$price_d= substr($row[price], 0, strlen($row[price]) -2);
$price_c= substr($row[price], -2, 2);
?>
<div style="margin-left: 5px; margin-right: 5px;">$<?echo$price_d.','.$price_c;?></div>
		</td>
		<td align="left" <?echo$bg;?>>
<div style="margin-left: 5px; margin-right: 5px;"><?echo$row[stock];?></div>
		</td>
		<td align="left" <?if($row[online]=='yes'){echo'bgcolor="green"';}else{echo'bgcolor="red"';}?>>
<div style="margin-left: 5px; margin-right: 5px;"><?echo$row[online];?></div>
		</td>
		<td align="left" <?if($row[home]=='yes'){echo'bgcolor="green"';}else{echo$bg;}?>>
<div style="margin-left: 5px; margin-right: 5px;"><form name="home<?echo $row[code]?>" method="POST" action="acciones/products_home.php">
<input type="hidden" name="id" value="<?echo$row[id]?>">
<input type="hidden" name="codigo" value="<?echo$row[code]?>">
<?if ($row[home]=='yes'){$check_h='checked';}else{$check_h='';}?>
<input type="checkbox" name="home" <?echo$check_h?> value="yes">
<br>
<input type="submit" value="Public"></form></div>
		</td>
		<td align="left" <?echo$bg;?>>
<div style="margin-left: 5px; margin-right: 5px;">
<?$row[promotions].'<br>';
$result_r=mysql_query("SELECT * FROM promotions ORDER BY nombre DESC");
$e='0';
$w_r='0';
$cadena_r=$row[promotions];
while($row_r = mysql_fetch_array($result_r, MYSQL_ASSOC)){
$palabra_r=str_replace(' ', '', $row_r[code]); 
if(eregi("[ z\t\n\r]+".$palabra_r."[ z\t\n\r]+",$cadena_r)){
echo$row_r[nombre].'<br>';
}$e++;$w_r++;}?>
<br>
<span style="cursor: pointer" onclick="location.href='products_promotion.php?id=<?echo$row[id]?>'"><b>Edit</b></span>
</div>
		</td>
		<td align="right" <?echo$bg;?>>
<span style="cursor: pointer" onclick="location.href='products_max_edit.php?id=<?echo$row[id]?>'"><b>Max Edit</b></span>&nbsp;<br>
<span style="cursor: pointer" onclick="location.href='products_data_edit.php?code=<?echo$row[code]?>'"><b>Data Edit</b></span>&nbsp;<br>
<span style="cursor: pointer" onclick="location.href='products_faq_edit.php?code=<?echo$row[code]?>'"><b>FAQ Edit</b></span>&nbsp;<br>
<span style="cursor: pointer" onclick="location.href='products_image_edit.php?id=<?echo$row[id]?>'"><b>Image Edit</b></span>&nbsp;
		</td>
	</tr>


<form name="m_f_<?echo$w;?>" method="POST" action="acciones/products_edit.php">
		<tr id="m_<?echo$w;?>" style="display: none;">
		<td align="left" <?echo$bg;?>>
	<?if(file_exists('../img_products/'.$row[code].'-1_c.jpg')){?>
<img src="../img_products/<?echo $row[code]?>-1_c.jpg">
	<?}else{echo'<font color="red">WITHOUT PHOTO,<br>I DO NOT KNOW IT PUBLISHES</font>';}?>
<input type="hidden" name="id" value="<?echo$row[id];?>">
<input type="hidden" name="code" value="<?echo$row[code];?>">
		</td>
		<td align="left" bgcolor="#ffffff">
<div style="margin-left: 5px; margin-right: 5px;"><?echo$row[code]?></div>
		</td>
		<td align="left" bgcolor="#ffffff">
<div style="margin-left: 5px; margin-right: 5px;"><?echo$row[name]?></div>
		</td>
		<td align="left" bgcolor="#ffffff">
<div style="margin-left: 5px; margin-right: 5px;">
<?
$price_d= substr($row[price], 0, strlen($row[price]) -2);
$price_c= substr($row[price], -2, 2);
?>
$<input type="text" name="price_d" value="<? echo $price_d;?>" size="6">,
<input type="text" name="price_c" value="<? echo $price_c;?>" size="2">
</div>
		</td>
		<td align="left" bgcolor="#ffffff">
<div style="margin-left: 5px; margin-right: 5px;">
<?if ($row[stock]=='yes'){$check_s='checked';}?>
<input type="checkbox" name="stock" <?echo$check_s?> value="yes"></div>
		</td>
		<td align="left" <?if($row[online]=='yes'){echo'bgcolor="green"';}else{echo'bgcolor="red"';}?>>
<div style="margin-left: 5px; margin-right: 5px;">
<?if ($row[online]=='yes'){$check_o='checked';}?>
<input type="checkbox" name="online" <?echo$check_o?> value="yes"></div>
		</td>
		<td>
In home
		</td>
		<td align="left" bgcolor="#ffffff">
<div style="margin-left: 5px; margin-right: 5px;">
<?if ($row[promotions]=='yes'){$check_p='checked';}?>
<input type="checkbox" name="promotions" <?echo$check_p?> value="yes"></div>
		</td>
		<td align="left" bgcolor="#ffffff">
<div style="margin-left: 5px; margin-right: 5px;">
Delete&nbsp;<input type="checkbox" name="borrar" value="yes"><br>
<br>
<input type="submit" value="Save Edit"><br>
<br>
<span style="cursor: pointer;" onclick="document.getElementById('m_<?echo$w;?>').style.display = 'none'; document.getElementById('d_<?echo$w;?>').style.display = 'table-row'">close edit</span>
</div>
		</td>
	</tr>
</form>

<?$bg_num++;
$w++;}?>
</table>
</div>
<br>
		</td>
	</tr>
</table>
<table width="800" border="0" class="admin_area" cellspacing="0" cellpadding="0">
	<tr>
		<td height="3">

		</td>
	</tr>
	<tr bgcolor="#ffffff">
		<td align="right">
<?include('inc/foot.php');?>
		</td>
	</tr>
</table>
<!-- fin contenido -->
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
</center>
 </BODY>
</HTML>
<?Desconectar();?>